package com.cc.blog.web.controller;

import com.cc.blog.common.annotation.ApiOperationLog;
import com.cc.blog.common.utils.Result;
import com.cc.blog.web.domain.dto.FindWikiArticlePreNextReqDTO;
import com.cc.blog.web.domain.dto.FindWikiCatalogListReqDTO;
import com.cc.blog.web.service.WikiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 知识库
 * @Author cc
 * @Date 2025/1/13 10:36
 */
@RestController
@RequestMapping("/wiki")
@Api(tags = "知识库")
@AllArgsConstructor
public class WikiController {

    private final WikiService wikiService;

    @PostMapping("/list")
    @ApiOperation(value = "获取知识库数据")
    @ApiOperationLog(description = "获取知识库数据")
    public Result findWikiList() {
        return wikiService.findWikiList();
    }

    @PostMapping("/catalog/list")
    @ApiOperation(value = "获取知识库目录数据")
    @ApiOperationLog(description = "获取知识库目录数据")
    public Result findWikiCatalogList(@RequestBody @Validated FindWikiCatalogListReqDTO findWikiCatalogListReqDTO) {
        return wikiService.findWikiCatalogList(findWikiCatalogListReqDTO);
    }

    @PostMapping("/article/preNext")
    @ApiOperation(value = "获取知识库文章上下页")
    @ApiOperationLog(description = "获取知识库文章上下页")
    public Result findArticlePreNext(@RequestBody FindWikiArticlePreNextReqDTO findWikiArticlePreNextReqDTO) {
        return wikiService.findArticlePreNext(findWikiArticlePreNextReqDTO);
    }

}
